package com.iring.service.common.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iring.dao.common.LogDao;
import com.iring.domain.common.OperateLog;
import com.iring.service.common.LogService;

/**
 * 日志实现类
 *
 * @author wanggan
 **/
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogDao logDao;

    public LogServiceImpl() {
    }

    @Override
    public OperateLog saveLog(String username, String event, String ip, Boolean result, String remark) {
        OperateLog operateLog = new OperateLog();
        operateLog.setUsername(username);
        operateLog.setOperationEvent(event);
        operateLog.setOperationIp(ip);
        operateLog.setOperationResult(result);
        operateLog.setRemark(remark);
        return logDao.save(operateLog);
    }

    @Override
    public OperateLog saveLog(String username,String event, String ip,Boolean result) {
        OperateLog operateLog = new OperateLog();
        operateLog.setUsername(username);
        operateLog.setOperationEvent(event);
        operateLog.setOperationIp(ip);
        operateLog.setOperationResult(result);
        return logDao.save(operateLog);
    }

    /**
     * 保存日志信息
     *
     * @param operateLog
     *            {@link OperateLog}
     *
     * @return {@link OperateLog}
     */
    @Override
    public OperateLog save(OperateLog operateLog) {
        return logDao.save(operateLog);
    }
}
